<?php
	class WebModel extends CI_Model {
		// 表名
		static $bannerTable = "web_banner";
		static $newsTable = "web_news";
		static $productCategoryTable = "web_product_category";
		static $productTable = "web_product";
		static $caseTable = "web_case";

	    public function __construct() {
	        parent::__construct();
	    }

	    // 获取轮播图列表
	    public function get_banner_list($params = ""){
	    	$this->db->where('is_delete', 0);
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$bannerTable);
	    	return $this->db->order_by("`sort` DESC")->get(self::$bannerTable)->result_array();
		}

	    // 获取轮播图列详情
	    public function get_banner_info($id){
	    	$this->db->where('id', $id);
	    	return $this->db->get(self::$bannerTable)->row_array();
		}

	    // 获取新闻列表
	    public function get_news_list($params = ""){
	    	$this->db->where('is_delete', 0);
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$newsTable);
	    	return $this->db->order_by("`updatetime` DESC")->get(self::$newsTable)->result_array();
		}

	    // 获取新闻详情
	    public function get_news_info($id){
	    	$this->db->where('id', $id);
	    	return $this->db->get(self::$newsTable)->row_array();
		}
		
	    // 获取产品分类列表
	    public function get_product_category_list($params = ""){
	    	$this->db->where('is_delete', 0);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$productCategoryTable);
	    	return $this->db->order_by("`sort` DESC")->get(self::$productCategoryTable)->result_array();
		}

	    // 获取产品分类详情
	    public function get_product_category_info($id){
	    	$this->db->where('id', $id);
	    	return $this->db->get(self::$productCategoryTable)->row_array();
		}

	    // 获取产品列表
	    public function get_product_list($params = ""){
			$this->db->where('is_delete', 0);
			if(isset($params['cateId']) && $params['cateId']) {
				$this->db->where('cate_id', $params['cateId']);
			}
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$productTable);
	    	return $this->db->order_by("`sort` DESC, 'createtime' DESC")->get(self::$productTable)->result_array();
		}

	    // 获取产品详情
	    public function get_product_info($id){
	    	$this->db->where('id', $id);
	    	return $this->db->get(self::$productTable)->row_array();
		}
		
	    // 获取案例列表
	    public function get_case_list($params = ""){
	    	$this->db->where('is_delete', 0);
	    	// 分页
	    	if(isset($params['pageStart']) && isset($params['pageSize'])) $this->db->limit($params['pageSize'], $params['pageStart']);
	    	// 是否只获取条数
	    	if(isset($params['getRowNumber'])) return $this->db->count_all_results(self::$caseTable);
	    	return $this->db->order_by("`sort` DESC, `updatetime` DESC")->get(self::$caseTable)->result_array();
		}

	    // 获取案例详情
	    public function get_case_info($id){
	    	$this->db->where('id', $id);
	    	return $this->db->get(self::$caseTable)->row_array();
	    }
	}